<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>注册 - SimpleHire</title>
    <link
      th:href="@{/webjars/bootstrap/5.3.0/css/bootstrap.min.css}"
      rel="stylesheet"
    />
  </head>
  <body class="bg-light">
    <div class="container mt-5">
      <div class="row justify-content-center">
        <div class="col-md-6">
          <div class="card shadow">
            <div class="card-body p-5">
              <h2 class="card-title text-center mb-4">注册 SimpleHire</h2>

              <div
                th:if="${error}"
                class="alert alert-danger"
                role="alert"
                th:text="${error}"
              ></div>

              <form th:action="@{/register}" th:object="${user}" method="post">
                <div class="mb-3">
                  <label for="username" class="form-label">用户名</label>
                  <input
                    type="text"
                    class="form-control"
                    id="username"
                    th:field="*{username}"
                    required
                  />
                  <div
                    th:if="${#fields.hasErrors('username')}"
                    class="text-danger"
                    th:errors="*{username}"
                  ></div>
                </div>
                <div class="mb-3">
                  <label for="email" class="form-label">邮箱</label>
                  <input
                    type="email"
                    class="form-control"
                    id="email"
                    th:field="*{email}"
                    required
                  />
                  <div
                    th:if="${#fields.hasErrors('email')}"
                    class="text-danger"
                    th:errors="*{email}"
                  ></div>
                </div>
                <div class="mb-3">
                  <label for="password" class="form-label">密码</label>
                  <input
                    type="password"
                    class="form-control"
                    id="password"
                    th:field="*{password}"
                    required
                  />
                  <div
                    th:if="${#fields.hasErrors('password')}"
                    class="text-danger"
                    th:errors="*{password}"
                  ></div>
                </div>
                <button type="submit" class="btn btn-primary w-100">
                  注册
                </button>
              </form>

              <hr />
              <div class="text-center">
                <p>已有账号？ <a th:href="@{/login}">立即登录</a></p>
                <p><a th:href="@{/}">返回首页</a></p>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <script
      th:src="@{/webjars/bootstrap/5.3.0/js/bootstrap.bundle.min.js}"
    ></script>
  </body>
</html>
